package com.webchat.client.payment.service;


import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.exception.BusinessException;
import com.webchat.domain.vo.request.act.ResourceBehaviorRequestVO;
import com.webchat.rmi.act.IResourceBehaviorClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ResourceBehaviorService {


    @Autowired
    private IResourceBehaviorClient resourceBehaviorClient;


    /**
     * 资源基础互动操作
     *
     * @param resourceBehaviorRequest
     * @return
     */
    public Long behavior(ResourceBehaviorRequestVO resourceBehaviorRequest) {

        APIResponseBean<Long> responseBean = resourceBehaviorClient.behavior(resourceBehaviorRequest);
        if (APIResponseBeanUtil.isOk(responseBean)) {
            return responseBean.getData();
        }
        throw new BusinessException("操作失败");
    }

    /**
     * 取消资源基础互动操作
     *
     * @param resourceBehaviorRequest
     * @return
     */
    public Long cancelBehavior(ResourceBehaviorRequestVO resourceBehaviorRequest) {

        APIResponseBean<Long> responseBean = resourceBehaviorClient.cancelBehavior(resourceBehaviorRequest);
        if (APIResponseBeanUtil.isOk(responseBean)) {
            return responseBean.getData();
        }
        throw new BusinessException("操作失败");
    }
}
